package com.lvjunxiong.serviceinterface.click;


import com.lvjunxiong.serviceinterface.LunbotuModel;
import common.database.DBManager;
import common.util.CommUtil;
import org.apache.log4j.Logger;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lvjunxiong on 2019/7/10.
 */
public class ClickDao {
    private static final Logger logger = Logger.getLogger(ClickDao.class);


    public int clickLog(String type, String userid, String content) {
        int i =0;
        DBManager dbm = null;
        try {
            dbm = new DBManager();
            String sql = "insert into sh_log(id,createtime,type,userid,content) values('"+ CommUtil.getID() +"','"+ System.currentTimeMillis() +"','"+ type +"','"+ userid +"','"+ content +"')";
            i = dbm.executeUpdate(sql);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            dbm.close();
        }
        return i;
    }

    public LbtModel queryLbt(String lbtid) {
        LbtModel model = null;
        DBManager dbm = null;
        try {
            dbm = new DBManager();
            String sql = "select id,title from sh_lunbotu where id = '"+ lbtid +"'";
            model = (LbtModel) dbm.getObject(LbtModel.class,sql);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            dbm.close();
        }
        return model;
    }

    public LbtModel queryZX(String lbtid) {
        LbtModel model = null;
        DBManager dbm = null;
        try {
            dbm = new DBManager();
            String sql = "select id,title from sh_content where 1=1 and id = '"+ lbtid +"'";
            model = (LbtModel) dbm.getObject(LbtModel.class, sql);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            dbm.close();
        }
        return model;
    }
}